package cn.java.basic;

public class VariableConstant
{
    public static void main(String[] args)
    {
        double dPrice=99.99;
        double dSum=0;
        float  fPrice;
        float  fSum=0;
        int    nPrice;

        /**
         * 显示转换
         */
        fPrice=(float) dPrice;  //显式转换,有精度损失?
        nPrice=(int)dPrice;     //显示转换,有精度损失?
        for (int i = 0; i <100 ; i++)
        {
            fSum +=fPrice;
        }

        for (int i = 0; i <100 ; i++)
        {
            dSum +=dPrice;
        }
        System.out.println(fSum);
        System.out.println(dSum);
        System.out.println(nPrice*100);


        /**
         * 隐式转换
         */

        byte bCount=99;
        char cCount;
        int  nCount;
        long lCount;
        float fCount;
        double dCount;

        cCount=(char) bCount;
        nCount=bCount;
        lCount=bCount;
        fCount=bCount;
        dCount=bCount;
        System.out.println("-------------隐式转换-------------");
        System.out.println(cCount);
        System.out.println(nCount);
        System.out.println(lCount);
        System.out.println(fCount);
        System.out.println(dCount);

        /**
         * 常量
         */

        final char a=97,b=98,c=99;
        final int nSum=99;
        //nSum=90;
        System.out.println("-------------常量数值-------------");
        System.out.println(a+""+b+""+c);
        System.out.println(nSum);



    }
}
